import { createSlice } from "@reduxjs/toolkit";

const initialState = {
  // 当前路由名字
  currentRouteName: sessionStorage.getItem('title') || '仪表盘'
}
const baseSlice = createSlice({
  name: 'base',
  initialState,
  reducers: {
    setCurrentRoute(state, action) {
      // 动态设置头部面包屑当前路由名字
      state.currentRouteName = action.payload;
      // 持久化
      sessionStorage.setItem('title', state.currentRouteName)
    }
  }
})

export const { setCurrentRoute } = baseSlice.actions;
export default baseSlice.reducer;